﻿/*
 * Last review by   : Yaser
 * Last review date : JUL-21-09
 */
using System;
using System.Collections.Generic;
using System.Data;
using System.Xml;
using System.Text;
using ERP.Business.DataTypes.Company;
using ERP.Framework.Components.SerializationHelper;
using ERP.Framework.Components.Utilities.TracingHelper;
using ERP.Framework.Components.DatabaseHelper;
using ERP.Framework.Components.DatabaseHelper.Providers;

namespace ERP.Business.Company.Policy
{
    /// <summary>
    /// Public Holidays Manager
    /// </summary>
    public abstract class PublicHolidaysManager
    {
        /*
        private const string TRACIG_CATEGORY = "ERP.Business.CompanyManagers.Policy.PublicHolidaysManager" ,
            SP_GET_HOLIDAY = "SP_PUBLIC_HOLIDAY_GET",            
            TABLE_NAME = "PublicHoliday";

        /// <summary>
        /// Get single public holiday entry
        /// </summary>
        /// <param name="holidayDate">holiday date</param>
        /// <returns>holiday entry</returns>
        public static PublicHoliday GetPublicHoliday(DateTime holidayDate)
        {
            PublicHoliday ret = null ;
            PublicHolidaysCollection pubHol = GetPublicHolidays(holidayDate, holidayDate);
            if (pubHol != null && pubHol.Count > 0)
                ret = pubHol[0];
            return ret;
        }

        public static PublicHolidaysCollection GetPublicHolidays(DateTime startDate, DateTime endDate)
        {
            TraceUtil.Write(TRACIG_CATEGORY, "GetPublicHolidays : Start", DateTime.Now);
            GeneralDatabaseProvider con = new GeneralDatabaseProvider(DatabaseConstants.AdministrationDatabase);
            ParametersCollection param = new ParametersCollection();
            param.AddParameter("startDate", startDate, ParameterType.DateTime, ERP.Framework.Components.DatabaseHelper.ParameterDirection.InParameter);
            param.AddParameter("endDate", endDate, ParameterType.DateTime, ERP.Framework.Components.DatabaseHelper.ParameterDirection.InParameter);
            DataTable table = con.Read(ERP.Framework.Components.DatabaseHelper.CommandType.StoredProcedure,
                SP_GET_HOLIDAY, param);

            PublicHolidaysCollection obj = null;
            if (table != null && table.Rows.Count > 0)
            {
                table.TableName = "PublicHolidaysCollection";
                StringBuilder sb = new StringBuilder();
                using (XmlWriter x = XmlWriter.Create(sb))
                {
                    table.WriteXml(x);
                }
                obj = (PublicHolidaysCollection)XmlSerializingManager.DeserializeObject<PublicHolidaysCollection>(sb.ToString());
            }

            TraceUtil.Write(TRACIG_CATEGORY, "GetPublicHolidays : End", DateTime.Now);
            return obj;
        }

        /// <summary>
        /// Get all holiday entries for a certain year
        /// </summary>
        /// <param name="year">year</param>
        /// <returns>holiday entries</returns>
        public static PublicHolidaysCollection GetPublicHolidays(int year)
        {
            DateTime startdate = new DateTime(year, 1, 1);
            DateTime enddate = new DateTime(year, 12, 31);
            return GetPublicHolidays(startdate, enddate);
        }
         * */
    }
}
